<template>
	<view class="jobDetailPage">
		<view class="jobCard  mL15 mR15">
			<view class="w100 u-3  line28">
				<text class="font20 bold pR5">{{info?.oddJobName}}</text>
				<u-tag :text="info?.izUrgentText" bg-color="#fff" class="jpTag" :color="'#FF0000'"
					:border-color="'#FF0000'" v-show="info?.izUrgent==1" />
				<u-tag v-if="info.recruitmentCarefree&&info.recruitmentCarefree.indexOf('10')>=0" text="用工无忧"
					bg-color="#EAF4FE" class="zgTag" :color="'#3291F8'" :border-color="'#EAF4FE'" />
			</view>
			<view class="flex alg-center mT5">
				<view class="jobTime">{{info?.jobBeginDatetime}}-{{info?.jobEndDatetime}}</view>
				<view class="jobTime">{{info?.salaryPaymentText}}</view>
				<view class="jobTime">招{{info?.oddJobUseNum}}人</view>
			</view>
			<view class="flex jst-between alg-center">
				<view class="">
					<text class="font24 u-red bold">{{info?.salary}}</text>
					<text class="u-red font14 bold">元</text>
				</view>
				<view class="font13 ua">
					发布于{{info?.timediffStr}}
				</view>
			</view>
			<view class="mT10 posBox">
				<view class="jobPos flex alg-center pT10">
					<image class="posImg" :src="resources.posIcon" mode=""></image>
					<text class="mL5 font15 u-3">{{info?.provinceName}}-{{info?.cityName}}-{{info?.areaName}}</text>
				</view>
				<view class="flex  jst-between mT5">
					<view class="u-8bd font13 pL20 w80">
						{{info?.hopeWorkAddress}}
					</view>
					<view class="u-6 font13">
						{{info?.distance}}
					</view>
				</view>
			</view>

		</view>

		<view class="flex alg-center jst-between mT20 pL10 pR10">
			<block v-for="(item,i) in tabLis" :key="i">
				<view @click="changeTab(item,i)" class="tabItem font15" :class="curretnTab==i?'active':''">
					<text class="relative">{{item.text}}</text>
				</view>
			</block>
		</view>
		<view class="mT10">
			<view class="mT15 flex jst-between pL20 pR15 mB15">
				<block v-if="curretnTab==0">
					<text class="font17">我的推荐 {{total}}</text>
				</block>
				<block v-else>
					<text class="font17">{{tabLis[curretnTab].text}} {{total}}</text>
				</block>
			</view>
			<mescroll-uni class="lisBox" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
				:down="downOption" :up="upOption" :bottombar="false" :top="topH">
				<view class="bfRa pL15 pR15 pT15 pB15 mL15 mR15 mB10 " v-for="(item,i) in list" :key="i">
					<view class="flex  alg-center jst-between " >
						<view class="w70"
							@click.stop="xf.onlineUtils.route(`pages/common/personOrcompnayInfo/index?id=${item.id}&isPerson=2`)">
							<text class="font18 bold u-3">{{item.realName}}</text>
							<text class="font14 u-6 mL5">手机尾号:{{xf.getLen(item.userPhoneNo)}}</text>
						</view>
						<view class="flex alg-center">
							<image @click="phoneLink(item)" class="imgW54" :src="resources.job.cirMessage" mode=""></image>
							<image @click="chatJump(item)" class="mL10 imgW54" :src="resources.job.cirPhone" mode=""></image>
						</view>
					</view>
					<view class="jobPos flex  mT10">
						<image class="imgW32" :src="resources.posIcon" mode=""></image>
						<text class="posTxt mL5 txt-ellipsis" style="width: calc(100% - 46rpx);">{{item.homeAddress}}</text>
					</view>
					<!-- <block v-if="curretnTab!=0&&curretnTab!=1">
						<view class="flex jst-between alg-center mT10 u-border-top pT10">
							<text class="font15">开始时间</text>
							<text class="font15 bold">{{item.jobBeginTime}}</text>
						</view>
						<block v-if="curretnTab!=2">
							<view class="flex jst-between alg-center mT10">
								<text class="font15">结束时间</text>
								<text class="font15 bold">{{item.jobEndTime}}</text>
							</view>
							<block v-if="curretnTab!=3">
								<view class="flex jst-between alg-center mT10">
									<text class="font15">支付金额</text>
									<text class="font15 bold u-red">{{item.paymentAmount}}元</text>
								</view>
								<view class="flex jst-between alg-center mT10">
									<text class="font15">预计佣金</text>
									<text class="font15 bold u-red">{{item.expectIncome}}元</text>
								</view>
							</block>
						</block>
					</block>
				 -->
				</view>
			</mescroll-uni>
		</view>
		<xfTipModal ref="tipModal"></xfTipModal>
	</view>
</template>

<script>
	import {
		getJobInfoEno,
		getTjUserLis,
		getBmUserLis
	} from '@/api/economicInterface/user.js'
	
	import workerJob from "@/components/company/jobCard/index.vue"
	import {
		getLocal
	} from "@/libs/map.js"
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		components: {
			workerJob
		},
		mixins: [MescrollMixin],
		data() {
			return {
				loading: false,
				id: null,
				showModal: false,
				info: null,
				tx: null,
				curretnTab: 0,
				latitude: "",
				longitude: "",
				downOption: {
					use: true,
					auto: false
				},
				upOption: {
					page: {
						num: 0,
						size: 10,
						time: null
					},
					empty: {
						use: true,
						icon: '/static/image/nodata.png',
						tip: "暂无数据",
						fixed: true
					},
					textNoMore: "到底啦~",
				},
				topH:0,
				flagSetH: true,
				list: [],
				total:0,
				tabLis: [{
						value: 0,
						text: "已推荐"
					},
					{
						value: "0",
						text: "已报名"
					},
					{
						value: "1",
						text: "已录用"
					},
					{
						value: "4",
						text: "已完成"
					},
				]
			};
		},
		watch: {
			info() {
				if (this.flagSetH == true) {
					this.$nextTick(() => {
						this.getElementScollTop()
						this.flagSetH = false;
						console.log(this.flagSetH)
					})
				}
			},
		},
		async onLoad(e) {
			this.jobId = e.id;
			this.getDetail(this.jobId)

		},
		methods: {
			chatJump(item) {
				let info = {
					id:item.id,
					realName:item.realName,
					headImage:"",
					online:""
				}
				this.chatStore.addFriend(info)
			},
			//获取滚动框距离顶部距离
			getElementScollTop() {
				const query = uni.createSelectorQuery()
				query.select('.lisBox').boundingClientRect((data) => {
						this.topH = Math.round(data.top)+'px'
						console.log(this.topH)
					}).exec()
			},
			changeTab(item, i) {
				this.curretnTab = i;
				this.list = [];
				this.mescroll.resetUpScroll();
			},
			async upCallback(page) {
				if (page.num = 1) this.list = []
				let query, func;
				if (this.curretnTab == 0) {
					query = {
						"xfOddjobInfoId": this.jobId,
						"pageNo": 1,
						"pageSize": 10
					}
					func = getTjUserLis
				} else {
					query = {
						"xfOddjobInfoId": this.jobId,
						 enrollStatus: this.tabLis[this.curretnTab].value,
						"pageNo": 1,
						"pageSize": 10
					}
					func = getBmUserLis
				}
				query.pageNo = page.num;
				
				
				func(query).then(res => {
					let list = res.result.records;
					this.list = this.list.concat(list);
					this.total = res.result.total;
					this.mescroll.endSuccess(res.result.records.length);
				}).catch(err => {
					this.mescroll.endByPage(0, 0);
					this.mescroll.endSuccess(1);
					this.mescroll.endErr();
				})
			},
			async getDetail(id) {
				this.info=null;
				const {lat,lon} = await this.xf.getLatOrLon()
				getJobInfoEno({
					xfOddjobInfoId: id,
					latitude: lat,
					longitude: lon
				}).then(res => {
					this.info = res.result
				})
			},
			phoneLink(v){
				let that=this;
				this.$refs.tipModal.open({
					content: "确认拨打电话吗？",
					btnText: "拨打",
					showCancel: true,
					success: function() {
						that.callNumber(v)
					}
				})
			},
			callNumber(v){
				this.xf.callPhone({
					acquirerId:v.xfOddGeneralId,
					details: 10
				})
			}
			

		}
	};
</script>
<style lang="scss">
	page {
		min-height: 100%;
			background: linear-gradient(0deg, #F8FAFF, #EBFCFF);
	}
</style>
<style scoped lang="scss">
	.orderCard {
		background: linear-gradient(#F5F7FF 10%, #FFFFFF);
		border-radius: 30rpx;
	}

	.jgGs {
		border-bottom: 2rpx solid #F6F6F6;
	}

	.tabItem {
		// margin-right: 58rpx;
		position: relative;

		.relative {
			z-index: 1;
		}

		&:first-child {
			margin-left: 20rpx;
		}

		&:last-child {
			margin-right: 30rpx;
		}

		&.active {
			font-weight: bold;

			&:before {
				content: "";
				position: absolute;
				bottom: 0;
				z-index: 0;
				width: 100%;
				height: 10rpx;
				background: linear-gradient(to right, #3291F8, #E4F1FE);
				border-radius: 2rpx 2rpx 2rpx 2rpx;
			}
		}
	}


	.rightImg {
		width: 9rpx;
		height: 18rpx;
	}

	.phoneImg {
		width: 48rpx;
		height: 48rpx;
		margin: 0 auto;
	}

	.posBox {
		border-top: 2rpx solid #F6F6F6;
	}

	.companyInfo {
		width: calc(100% - 110rpx);
	}

	.jobCard {
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		.jobLeft {
			max-width: 70%;
		}

		.jobStatus {
			border: 2rpx solid #FF0000;
			border-radius: 10rpx;
			height: 34rpx;
			line-height: 34rpx;
			padding: 0 10rpx;
			margin-right: 10rpx;
		}

		.jobTag {
			height: 34rpx;
			line-height: 34rpx;
			padding: 0 10rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
		}

		.jobMoney {
			word-break: keep-all;
		}

		.jobTime {
			color: #8D8D8D;
			font-size: 26rpx;
			margin-right: 10rpx;
			height: 44rpx;
			line-height: 44rpx;
			padding: 0 10rpx;
			background: #F8F8F8;
			border-radius: 6rpx;
			margin-top: 16rpx;
		}

		.posImg {
			width: 32rpx;
			height: 32rpx;
		}

		.posTxt {
			width: calc(100% - 42rpx);
			font-weight: 400;
			font-size: 26rpx;
			color: #8D8D8D;
		}

		.companyImg {
			width: 48rpx;
			height: 48rpx;
		}

		.rzImg {
			width: 24rpx;
			height: 24rpx;
		}

		.companyName {
			font-weight: 500;
			font-size: 30rpx;
			color: #333;
			margin-right: 10rpx;
			margin-left: 10rpx;
		}
	}
</style>